﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnBoss : MonoBehaviour
{
    public float TimeToSpawn;
    public SpawnPosition[] ArraySpawnPos;

    public GlobalDefine.CarMovementDir[] ArrayDir;
    public SpawnCarMgr SpwnMgr;
    public GameObject BossObj;
    private float m_fTimeToSpawn;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }


    private void FixedUpdate()
    {
        if(SpwnMgr.IsActive())
        {
            m_fTimeToSpawn += Time.fixedDeltaTime;
            if (m_fTimeToSpawn >= TimeToSpawn)
            {
                m_fTimeToSpawn -= TimeToSpawn;
                int nIdx = Random.Range(0, ArrayDir.Length);
                GlobalDefine.CarMovementDir _dir = ArrayDir[nIdx];
                SpwnMgr.PublicGenerate(ArraySpawnPos[(int)_dir - 1], BossObj);
            }
        }
    }
}
